using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;

namespace Model
{
    public partial class PinghuoContext : DbContext
    {
        public PinghuoContext()
            : base("name=PinghuoContext")
        {
        }

        public virtual DbSet<TBLogins> TBLogins { get; set; }
        public virtual DbSet<TBUsers> TBUsers { get; set; }
        public virtual DbSet<Commodities> Commodities { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TBLogins>()
                .Property(e => e.UserName)
                .IsUnicode(false);

            modelBuilder.Entity<TBLogins>()
                .Property(e => e.MobileNumber)
                .IsUnicode(false);

            modelBuilder.Entity<TBLogins>()
                .Property(e => e.Password)
                .IsUnicode(false);

            modelBuilder.Entity<TBLogins>()
                .HasOptional(e => e.TBUsers)
                .WithRequired(e => e.TBLogins);

            modelBuilder.Entity<TBUsers>()
                .Property(e => e.NickName)
                .IsUnicode(false);

            modelBuilder.Entity<TBUsers>()
                .Property(e => e.Avatar)
                .IsUnicode(false);

            modelBuilder.Entity<TBUsers>()
                .Property(e => e.Address)
                .IsUnicode(false);

            modelBuilder.Entity<TBUsers>()
                .Property(e => e.Hobby)
                .IsUnicode(false);

            modelBuilder.Entity<Commodities>()
                .Property(e => e.ComId)
                .IsUnicode(false);

            modelBuilder.Entity<Commodities>()
                .Property(e => e.Name)
                .IsUnicode(false);

            modelBuilder.Entity<Commodities>()
                .Property(e => e.Phone)
                .IsUnicode(false);

            modelBuilder.Entity<Commodities>()
                .Property(e => e.Addr)
                .IsUnicode(false);

            modelBuilder.Entity<Commodities>()
                .Property(e => e.Openid)
                .IsUnicode(false);

            modelBuilder.Entity<Commodities>()
                .Property(e => e.Amount)
                .HasPrecision(8, 2);
        }
    }
}
